package com.eascs.deploy.dao;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.eascs.admin.common.dao.BaseO2oDao;
import com.eascs.deploy.entity.O2oDeployFile;
import com.eascs.deploy.entity.O2oDeployFileLink;

@Repository
public class DeployFileDao extends BaseO2oDao{
	public  List<O2oDeployFileLink> deployFile(String banktypeId, String formTypeId) {
		String sql = "SELECT * FROM o2o_archive_link WHERE bank_type_id=(SELECT item_no FROM pub_dditem_o2o WHERE item_code=?) and form_type_id IN (SELECT item_no FROM pub_dditem_o2o WHERE item_code=?)";
		Object[] params = new Object[]{banktypeId, formTypeId};
		return this.findEntitys(sql, O2oDeployFileLink.class, params);
	}
	public  List<O2oDeployFile> findAllFiles() {
		String sql = "SELECT * FROM pub_dditem_o2o WHERE dd_no='40002'";
		return this.findEntitys(sql, O2oDeployFile.class, new Object[]{});
		
	}
	public  String findId(String code) {
		String sql = "SELECT item_no FROM pub_dditem_o2o WHERE item_code=?";
		return this.findString(sql, new Object[]{code});
	}
	
	public  void insertFile(O2oDeployFileLink entity) {
		String sql = "INSERT INTO o2o_archive_link(id,bank_type_id,form_type_id,field_id,field_required,field_min,field_max)VALUES(?,?,?,?,?,?,?)";
		this.insert(entity);
		System.out.println(sql);
	}
	public void deleteFile(String bankTypeId, String formTypeId) {
		String sql = "DELETE FROM o2o_archive_link WHERE bank_type_id =? and form_type_id = ?";
		this.execute(sql,  new Object[]{bankTypeId,formTypeId});
	}
}
